﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for ProductDAL
/// </summary>
public class ProductDAL
{
    DataAccess db = new DataAccess();

    public ProductDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    //display all product
    public DataTable GetAllProduct()
    {
        return db.executeSelect("GetAllProduct");
    }


    //search  product by id
    public DataTable GetProductById(string productId)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@ProductId", SqlDbType.VarChar, 30);
        paramList[0].Value = productId;

        return db.executeSelect("GetProductById", paramList);
    }




    //search  product by Name

    public DataTable GetProductByName(string productName)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@ProductName", SqlDbType.VarChar, 30);
        paramList[0].Value = productName;

        return db.executeSelect("GetProductByName", paramList);
    }



    //search product by Color
    public DataTable GetProductAll(string categoryname, string color1, string color2, string color3, string color4, int size1, int size2, int size3, int size4, float price1, float price2)
    {
        SqlParameter[] paramList = new SqlParameter[9];
        paramList[0] = new SqlParameter("@categoryname", SqlDbType.VarChar, 30);
        paramList[0].Value = categoryname;
        paramList[1] = new SqlParameter("@Color1", SqlDbType.VarChar, 30);
        paramList[1].Value = color1;
        paramList[2] = new SqlParameter("@Color2", SqlDbType.VarChar, 30);
        paramList[2].Value = color2;
        paramList[3] = new SqlParameter("@Color3", SqlDbType.VarChar, 30);
        paramList[3].Value = color3;
        paramList[4] = new SqlParameter("@Color4", SqlDbType.VarChar, 30);
        paramList[4].Value = color4;
        paramList[4] = new SqlParameter("@categoryname", SqlDbType.VarChar, 30);

        paramList[5] = new SqlParameter("@Size1", SqlDbType.Int);
        paramList[5].Value = size1;
        paramList[5] = new SqlParameter("@Size2", SqlDbType.Int);
        paramList[5].Value = size2;
        paramList[5] = new SqlParameter("@Size3", SqlDbType.Int);
        paramList[6].Value = size3;
        paramList[6] = new SqlParameter("@Size4", SqlDbType.Int);
        paramList[6].Value = size4;
        paramList[7] = new SqlParameter("@Price1", SqlDbType.Float);
        paramList[7].Value = price1;
        paramList[8] = new SqlParameter("@Price2", SqlDbType.Float);
        paramList[8].Value = price2;
        return db.executeSelect("GetSearchAll", paramList);
    }

    //search img by categoryname
    public DataTable GetUrlImgbyCategoryName(string categoryname)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@CategoryName", SqlDbType.NVarChar, 30);
        paramList[0].Value = categoryname;


        return db.executeSelect("GetUrlImgByNamecategory", paramList);
    }



    public DataTable GetSearchAll01(string size1, string color1, float price1, float price2,string CategoryName)
    {
        SqlParameter[] paramList = new SqlParameter[5];
        paramList[0] = new SqlParameter("@CategoryName", SqlDbType.NVarChar, 30);
        paramList[0].Value = CategoryName;
        paramList[1] = new SqlParameter("@Size1", SqlDbType.NVarChar,30);
        paramList[1].Value = size1;
        paramList[2] = new SqlParameter("@Color1", SqlDbType.NVarChar, 30);
        paramList[2].Value = color1;
        paramList[3] = new SqlParameter("@Price1", SqlDbType.Float);
        paramList[3].Value = price1;
        paramList[4] = new SqlParameter("@Price2", SqlDbType.Float);
        paramList[4].Value = price2;

        return db.executeSelect("GetSearchAll02", paramList);
    }
}